namespace RuoVea.WeighIns.Server.Models;

/// <summary>
/// 体重记录主表
/// </summary>
[SugarTable(nameof(InsWeighInfo), "体重记录主表")]
public class InsWeighInfo : EntityBase
{
    /// <summary>
    /// 体重时间
    /// </summary>
    [SugarColumn(ColumnDescription = "体重时间", IsNullable = false)]
    public DateTime WeighTime { get; set; }

    /// <summary>
    /// 体重KG
    /// </summary>
    [SugarColumn(ColumnDescription = "体重KG", IsNullable = false)]
    public double WeighKg { get; set; }

    /// <summary>
    /// 时段ID
    /// </summary>
    [SugarColumn(ColumnDescription = "时段ID", IsNullable = false)]
    public int Meridiem { get; set; }

    /// <summary>
    /// 排序
    /// </summary>
    [SugarColumn(ColumnDescription = "排序", IsNullable = true, DefaultValue = "10")]
    public int Sort { get; set; } = 10;

    /// <summary>
    /// 备注
    /// </summary>
    [MaxLength(500)]
    [SugarColumn(ColumnDescription = "备注", IsNullable = true, ColumnDataType = StaticConfig.CodeFirst_BigString)]
    public string? Remark { get; set; }

    #region IsIgnore
    /// <summary>
    /// 时段信息（导航属性）
    /// </summary>
    [Navigate(NavigateType.OneToOne, nameof(Meridiem), nameof(InsMeridiem.Id))]
    public InsMeridiem? MeridiemInfo { get; set; }

    /// <summary>
    /// 身体指标扩展数据（导航属性）
    /// </summary>
    [Navigate(NavigateType.OneToMany, nameof(InsBodyMetrics.WeightRecordId))]
    public List<InsBodyMetrics>? BodyMetrics { get; set; }

    /// <summary>
    /// 体重（磅） - 计算属性
    /// </summary>
    [SugarColumn(IsIgnore = true)]
    public double WeighLb => WeighKg * 2.20462;

    /// <summary>
    /// 显示用体重时间（格式化）
    /// </summary>
    [SugarColumn(IsIgnore = true)]
    public string WeighTimeDisplay => WeighTime.ToString("yyyy-MM-dd HH:mm"); 
    #endregion
}


